package com.example.testdemo.coordinator;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 颜 on 04.28.028.
 */

public class MyAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> fragments;
    private List<String> titles;

    public MyAdapter(FragmentManager fragmentManager,List<String> titles) {
        super(fragmentManager);
        this.titles = titles;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    public void setFragments(ArrayList<Fragment> fragments) {
        this.fragments = fragments;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

}
